]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensions-tool/list: Allow filtering by (in)active state
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 21 Dec 2023 22:16:18 +0000 (23:16 +0100)
committerMarge Bot <marge-bot@gnome.org>
Wed, 3 Jan 2024 20:05:05 +0000 (20:05 +0000)
This brings back the filtering that the `--enable`/`--disable`
flags used to do, which can be useful as well.

For instance

  $ gnome-extensions list --active

to show all extensions currently in use, or

  $ gnome-extensions list --enabled --inactive

for extensions that are inactive despite being enabled.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7004

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3073>

subprojects/extensions-tool/man/gnome-extensions.txt
subprojects/extensions-tool/src/command-list.c

index 7fcc3811ed06adfe7bf7b1937a5f7b9dda6f4924..20d5fd4155d95f59a27531c0a5199ed1522b2937 100644 (file)
@@ -100,6 +100,12 @@ Displays a list of installed extensions.
   *--disabled*;;
     Include disabled extensions
 
+  *--active*;;
+    Only include extensions in active state
+
+  *--inactive*;;
+    Only include extensions in inactive state
+
   *--prefs*;;
     Only include extensions with preferences
 
index e5e4b8b95a48b5d8ada640b6d322e8b29246ab21..db6e81aedade82d80b65dfaf101b8de622988743 100644 (file)
@@ -32,8 +32,10 @@ typedef enum {
   LIST_FLAGS_SYSTEM   = 1 << 1,
   LIST_FLAGS_ENABLED  = 1 << 2,
   LIST_FLAGS_DISABLED = 1 << 3,
-  LIST_FLAGS_NO_PREFS = 1 << 4,
-  LIST_FLAGS_NO_UPDATES = 1 << 5,
+  LIST_FLAGS_ACTIVE   = 1 << 4,
+  LIST_FLAGS_INACTIVE = 1 << 5,
+  LIST_FLAGS_NO_PREFS = 1 << 6,
+  LIST_FLAGS_NO_UPDATES = 1 << 7,
 } ListFilterFlags;
 
 static gboolean
@@ -71,13 +73,14 @@ list_extensions (ListFilterFlags filter, DisplayFormat format)
   while (g_variant_iter_loop (&iter, "{s@a{sv}}", &uuid, &value))
     {
       g_autoptr (GVariantDict) info = NULL;
-      double type;
+      double type, state;
       gboolean has_prefs;
       gboolean has_update;
       gboolean enabled;
 
       info = g_variant_dict_new (value);
       g_variant_dict_lookup (info, "type", "d", &type);
+      g_variant_dict_lookup (info, "state", "d", &state);
       g_variant_dict_lookup (info, "enabled", "b", &enabled);
       g_variant_dict_lookup (info, "hasPrefs", "b", &has_prefs);
       g_variant_dict_lookup (info, "hasUpdate", "b", &has_update);
@@ -94,6 +97,12 @@ list_extensions (ListFilterFlags filter, DisplayFormat format)
       if (!enabled && (filter & LIST_FLAGS_DISABLED) == 0)
         continue;
 
+      if (state == STATE_ACTIVE && (filter & LIST_FLAGS_ACTIVE) == 0)
+        continue;
+
+      if (state != STATE_ACTIVE && (filter & LIST_FLAGS_INACTIVE) == 0)
+        continue;
+
       if (!has_prefs && (filter & LIST_FLAGS_NO_PREFS) == 0)
         continue;
 
@@ -121,6 +130,8 @@ handle_list (int argc, char *argv[], gboolean do_help)
   gboolean system = FALSE;
   gboolean enabled = FALSE;
   gboolean disabled = FALSE;
+  gboolean active = FALSE;
+  gboolean inactive = FALSE;
   gboolean has_prefs = FALSE;
   gboolean has_updates = FALSE;
   GOptionEntry entries[] = {
@@ -136,6 +147,12 @@ handle_list (int argc, char *argv[], gboolean do_help)
     { .long_name = "disabled",
       .arg = G_OPTION_ARG_NONE, .arg_data = &disabled,
       .description = _("Show disabled extensions") },
+    { .long_name = "active",
+      .arg = G_OPTION_ARG_NONE, .arg_data = &active,
+      .description = _("Show extensions in active state") },
+    { .long_name = "inactive",
+      .arg = G_OPTION_ARG_NONE, .arg_data = &inactive,
+      .description = _("Show extensions in inactive state") },
     { .long_name = "prefs",
       .arg = G_OPTION_ARG_NONE, .arg_data = &has_prefs,
       .description = _("Show extensions with preferences") },
@@ -186,6 +203,12 @@ handle_list (int argc, char *argv[], gboolean do_help)
   if (disabled || !enabled)
     flags |= LIST_FLAGS_DISABLED;
 
+  if (active || !inactive)
+    flags |= LIST_FLAGS_ACTIVE;
+
+  if (inactive || !active)
+    flags |= LIST_FLAGS_INACTIVE;
+
   if (!has_prefs)
     flags |= LIST_FLAGS_NO_PREFS;